package org.xtext.example.mydsl.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import org.xtext.example.mydsl.myDsl.Building;
import org.xtext.example.mydsl.myDsl.Circle;
import org.xtext.example.mydsl.myDsl.Door;
import org.xtext.example.mydsl.myDsl.Library;
import org.xtext.example.mydsl.myDsl.Margin;
import org.xtext.example.mydsl.myDsl.Model;
import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.Parametric;
import org.xtext.example.mydsl.myDsl.Point;
import org.xtext.example.mydsl.myDsl.Polygon;
import org.xtext.example.mydsl.myDsl.Prototype;
import org.xtext.example.mydsl.myDsl.Roof;
import org.xtext.example.mydsl.myDsl.Scene;
import org.xtext.example.mydsl.myDsl.Texture;
import org.xtext.example.mydsl.myDsl.Translation;
import org.xtext.example.mydsl.myDsl.Wall;
import org.xtext.example.mydsl.myDsl.Window;
import org.xtext.example.mydsl.services.MyDslGrammarAccess;

@SuppressWarnings("all")
public class MyDslSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private MyDslGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == MyDslPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case MyDslPackage.BUILDING:
				if(context == grammarAccess.getBuildingRule()) {
					sequence_Building(context, (Building) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.CIRCLE:
				if(context == grammarAccess.getCircleRule() ||
				   context == grammarAccess.getSurfaceRule()) {
					sequence_Circle(context, (Circle) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.DOOR:
				if(context == grammarAccess.getDoorRule() ||
				   context == grammarAccess.getOpeningRule()) {
					sequence_Door(context, (Door) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.LIBRARY:
				if(context == grammarAccess.getLibraryRule() ||
				   context == grammarAccess.getTypeRule()) {
					sequence_Library(context, (Library) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.MARGIN:
				if(context == grammarAccess.getMarginRule()) {
					sequence_Margin(context, (Margin) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.MODEL:
				if(context == grammarAccess.getModelRule()) {
					sequence_Model(context, (Model) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.PARAMETRIC:
				if(context == grammarAccess.getParametricRule()) {
					sequence_Parametric(context, (Parametric) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.POINT:
				if(context == grammarAccess.getPointRule()) {
					sequence_Point(context, (Point) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.POLYGON:
				if(context == grammarAccess.getPolygonRule() ||
				   context == grammarAccess.getSurfaceRule()) {
					sequence_Polygon(context, (Polygon) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.PROTOTYPE:
				if(context == grammarAccess.getPrototypeRule()) {
					sequence_Prototype(context, (Prototype) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.ROOF:
				if(context == grammarAccess.getRoofRule()) {
					sequence_Roof(context, (Roof) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.SCENE:
				if(context == grammarAccess.getSceneRule() ||
				   context == grammarAccess.getTypeRule()) {
					sequence_Scene(context, (Scene) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.TEXTURE:
				if(context == grammarAccess.getTextureRule()) {
					sequence_Texture(context, (Texture) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.TRANSLATION:
				if(context == grammarAccess.getTranslationRule()) {
					sequence_Translation(context, (Translation) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.WALL:
				if(context == grammarAccess.getWallRule()) {
					sequence_Wall(context, (Wall) semanticObject); 
					return; 
				}
				else break;
			case MyDslPackage.WINDOW:
				if(context == grammarAccess.getOpeningRule() ||
				   context == grammarAccess.getWindowRule()) {
					sequence_Window(context, (Window) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (name=ID translation=Translation? prototype=STRING)
	 */
	protected void sequence_Building(EObject context, Building semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         translation=Translation 
	 *         radius=STRING 
	 *         height=STRING 
	 *         texture=STRING? 
	 *         margin=Margin?
	 *     )
	 */
	protected void sequence_Circle(EObject context, Circle semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         translation=Translation? 
	 *         position=STRING? 
	 *         width=STRING? 
	 *         height=STRING? 
	 *         texture=STRING? 
	 *         margin=Margin?
	 *     )
	 */
	protected void sequence_Door(EObject context, Door semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID textures+=Texture* prototypes+=Prototype*)
	 */
	protected void sequence_Library(EObject context, Library semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID value=STRING texture=STRING?)
	 */
	protected void sequence_Margin(EObject context, Margin semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     elements+=Type*
	 */
	protected void sequence_Model(EObject context, Model semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         translation=Translation 
	 *         width=STRING 
	 *         length=STRING? 
	 *         height=STRING? 
	 *         texture=STRING?
	 *     )
	 */
	protected void sequence_Parametric(EObject context, Parametric semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (xCord=STRING yCord=STRING)
	 */
	protected void sequence_Point(EObject context, Point semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MyDslPackage.Literals.POINT__XCORD) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MyDslPackage.Literals.POINT__XCORD));
			if(transientValues.isValueTransient(semanticObject, MyDslPackage.Literals.POINT__YCORD) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MyDslPackage.Literals.POINT__YCORD));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getPointAccess().getXCordSTRINGTerminalRuleCall_2_0(), semanticObject.getXCord());
		feeder.accept(grammarAccess.getPointAccess().getYCordSTRINGTerminalRuleCall_4_0(), semanticObject.getYCord());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         translation=Translation 
	 *         width=STRING? 
	 *         height=STRING? 
	 *         texture=STRING? 
	 *         margin=Margin? 
	 *         points+=Point*
	 *     )
	 */
	protected void sequence_Polygon(EObject context, Polygon semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID translation=Translation walls+=Wall* openings+=Opening* roof=Roof?)
	 */
	protected void sequence_Prototype(EObject context, Prototype semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID elevation=STRING? texture=STRING?)
	 */
	protected void sequence_Roof(EObject context, Roof semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID parametrics+=Parametric* buildings+=Building* surfaces+=Surface*)
	 */
	protected void sequence_Scene(EObject context, Scene semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID imgURL=STRING? color=STRING?)
	 */
	protected void sequence_Texture(EObject context, Texture semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (xCord=STRING yCord=STRING zCord=STRING)
	 */
	protected void sequence_Translation(EObject context, Translation semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MyDslPackage.Literals.TRANSLATION__XCORD) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MyDslPackage.Literals.TRANSLATION__XCORD));
			if(transientValues.isValueTransient(semanticObject, MyDslPackage.Literals.TRANSLATION__YCORD) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MyDslPackage.Literals.TRANSLATION__YCORD));
			if(transientValues.isValueTransient(semanticObject, MyDslPackage.Literals.TRANSLATION__ZCORD) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MyDslPackage.Literals.TRANSLATION__ZCORD));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getTranslationAccess().getXCordSTRINGTerminalRuleCall_2_0(), semanticObject.getXCord());
		feeder.accept(grammarAccess.getTranslationAccess().getYCordSTRINGTerminalRuleCall_4_0(), semanticObject.getYCord());
		feeder.accept(grammarAccess.getTranslationAccess().getZCordSTRINGTerminalRuleCall_6_0(), semanticObject.getZCord());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         start=Point 
	 *         end=Point 
	 *         height=STRING 
	 *         texture=STRING 
	 *         door=Door? 
	 *         windows+=Window*
	 *     )
	 */
	protected void sequence_Wall(EObject context, Wall semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         translation=Translation? 
	 *         position=STRING? 
	 *         width=STRING? 
	 *         height=STRING? 
	 *         heightAboveGround=STRING? 
	 *         texture=STRING? 
	 *         margin=Margin? 
	 *         points+=Point*
	 *     )
	 */
	protected void sequence_Window(EObject context, Window semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
